<% layout('/layouts/default.html', {title: '内容管理管理', libs: ['validate','fileupload','ueditor']}){ %>
<style>
	.webuploader-pick{
		float:left;
	}
</style>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(content.isNewRecord ? '新增内容管理' : '编辑内容管理')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${content}" action="${ctx}/fl/content/save" method="post" class="form-horizontal">
			<div class="box-body">
				<#form:hidden path="id"/>
				<div class="row">
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('语言')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="lang" dictType="fl_language" blankOption="true" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('栏目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="type" dictType="fl_content_type" blankOption="true" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="title" maxlength="255" class="form-control required"/>
							</div>
						</div>
					</div>

				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('标题图片')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${content.id}" bizType="content_image"
								uploadType="image" class="" readonly="false" maxUploadNum="1" isMini="true" returnPath="true"
								filePathInputId="imgPaths" fileNameInputId="imgNames"/>
								<#form:hidden path="imgPaths"/>
								<#form:hidden path="imgNames"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">${text('摘要')}：</label>
							<div class="col-sm-10">
								<#form:input path="summary" maxlength="1000" class="form-control"/>
							</div>
						</div>
					</div>

				</div>
				<div class="row" id="enterprises-container" style="display:none;">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('针对的企业')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="enterprises" items="${enterpriseList}" itemLabel="name" itemValue="id" blankOption="true" multiple="true" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>

				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('内容')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:ueditor path="content" height="300" class="" readonly="false" outline="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${content.id}" bizType="content_file"
									uploadType="all" class="" readonly="false" filePathInputId="attachPaths" fileNameInputId="attachNames"  returnPath="true"/>
								<#form:hidden path="attachPaths"/>
								<#form:hidden path="attachNames"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('fl:content:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnPreview" onclick="openLayerPage('${ctx}/fl/content/view', '预 览', 411,731);"><i class="fa fa-eye"></i> ${text('预 览')}</button>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});

$("#type").unbind("change").change(function(){
   var val = this.value;
   if(val == "3"){
       $("#enterprises-container").show();
       $("#enterprises").addClass("required");
   } else{
       $("#enterprises-container").hide();
       $("#enterprises").val("");
       $("#enterprises").removeClass("required");
   }
});

$("#type").trigger("change");
</script>